{__NOLAYOUT__}
<form data-method="post" data-action="{:url('page/saveData');}" data-submit="ajax" data-validate="true" class="form-horizontal" id="editForm">
    <input type="hidden" value="{$data['id']}" name="id">
    <div class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span></button>
                    <h3 class="modal-title">{:lang('Edit')}</h3>
                </div>
                <div class="modal-body">
                    <div class="modal-body-content">
                        <div class="form-group must">
                            <label class="col-sm-3 control-label">位置</label>
                            <div class="col-sm-7">
                                <select name="type">
                                    <option value="1"  {if condition="$data['type']==1"}selected{/if} >内容</option>
                                    <option value="2" {if condition="$data['type']==2"}selected{/if}  >顶部</option>
                                </select>
                            </div>
                        </div>

                        <div class="form-group must">
                            <label class="col-sm-3 control-label">标题</label>
                            <div class="col-sm-7">
                                <input type="text" class="form-control" name="title" maxlength="100" placeholder="请输入标题" required value="{$data['title']}">
                            </div>
                        </div>

                        <div class="form-group must">
                            <label class="col-sm-3 control-label">排序</label>
                            <div class="col-sm-7">
                                <input type="text" class="form-control" name="sort" maxlength="5" value="99" placeholder="数值越大，排名越前" required value="{$data['sort']}">
                            </div>
                        </div>

                        <div class="form-group must">
                            <label class="col-sm-3 control-label">图片</label>
                            <div class="col-sm-7">
                                <input type="text" id="url" class="form-control" name="url" maxlength="255" placeholder="图片地址" required value="{$data['url']}">
                            </div>
                        </div>



                        <div class="form-group must">
                            <label class="col-sm-3 control-label">上传图片(自动上传)</label>
                            <div class="col-sm-7">
                                <input type="file" name="file" class="form-control" id="upfile"  >
                            </div>

                        </div>





                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">{:lang('Cancel')}</button>
                    <button type="submit" class="btn btn-primary">{:lang('Save')}</button>
                </div>
            </div>
        </div>
    </div>
</form>

{js href="__LIB__/upload.js" /}

<script type="text/javascript">
    $("#upfile").ajaxImageUpload({
        url: "{:url('page/upload')}", //上传的服务器地址
        data: { name:'file' },
        maxNum: 1, //允许上传图片数量
        zoom: true, //允许放大
        allowType: ["gif", "jpeg", "jpg", "bmp",'png'], //允许上传图片的类型
        maxSize :5, //允许上传图片的最大尺寸，单位M
        before: function () {
            console.log('上传前回调函数');
        },
        success:function(data){
            if(!data.status){
                alert(data.msg);
            }else{
                $('#url').val(data.src);
            }
        },
        error:function (e) {
            alert('上传失败');
            console.log(e);
        }
    });


</script>